package com.ayoka.parenting.ui.main;

import android.util.Log;

import com.ayoka.parenting.bean.UserInfoDetailBean;
import com.ayoka.parenting.bean.UserManager;
import com.ayoka.parenting.interf.SimpleRequestCallback;
import com.ayoka.parenting.mvp.BasePresenterImpl;
import com.tencent.ticsdk.core.TICManager;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: MainPresenter.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class MainPresenter extends BasePresenterImpl<MainContract.View> implements MainContract.Presenter{

    private MainModel model;

     public MainPresenter() {
        model = new MainModel();
     }

    public void getUserInformation() {
        model.getUserInformation(this, new SimpleRequestCallback<UserInfoDetailBean>() {
            @Override
            public void onSuccess(UserInfoDetailBean data) {
                if (!isAttached()) return;
                UserManager.getInstance().detailBean = data;
                UserManager.save();
                mView.get().onGetUserInformationCallback(true);
            }

            @Override
            public void onFailure(int errCode, String errMsg) {
                if (!isAttached()) return;
                mView.get().onGetUserInformationCallback(false);
            }
        });
    }

    public void quitTIC() {
        TICManager.getInstance().logout(new TICManager.TICCallback() {
            @Override
            public void onSuccess(Object data) {
               Log.d(TAG, "退出登录成功");
            }

            @Override
            public void onError(String module, int errCode, String errMsg) {
                Log.d(TAG, "退出登录失败" + errMsg);
            }
        });
    }
}
